home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 2002 November / SGI Freeware 2002 November - Disc 2.iso / dist / fw_hylafax.idb / var / freeware / spool / fax / bin / pdf2fax.gs.z / pdf2fax.gs
Text File  |  2002-07-08  |  4KB  |  125 lines

  1. #! /bin/sh
  2. #    $Id: pdf2fax.gs.sh.in,v 1.1 2002/02/17 23:31:19 darren Exp $
  3. #
  4. # HylaFAX Facsimile Software
  5. #
  6. # Copyright (c) 1990-1996 Sam Leffler
  7. # Copyright (c) 1991-1996 Silicon Graphics, Inc.
  8. # HylaFAX is a trademark of Silicon Graphics
  9. # Permission to use, copy, modify, distribute, and sell this software and 
  10. # its documentation for any purpose is hereby granted without fee, provided
  11. # that (i) the above copyright notices and this permission notice appear in
  12. # all copies of the software and related documentation, and (ii) the names of
  13. # Sam Leffler and Silicon Graphics may not be used in any advertising or
  14. # publicity relating to the software without the specific, prior written
  15. # permission of Sam Leffler and Silicon Graphics.
  16. # THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 
  17. # EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 
  18. # WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  
  19. # IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
  20. # ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
  21. # OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  22. # WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF 
  23. # LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 
  24. # OF THIS SOFTWARE.
  25. #
  26.  
  27. #
  28. # Convert PDF to facsimile using Ghostscript.
  29. #
  30. # pdf2fax [-o output] [-l pagelength] [-w pagewidth]
  31. #    [-r resolution] [-m maxpages] [-*] [file ...]
  32. #
  33. # We need to process the arguments to extract the input
  34. # files so that we can prepend a prologue file that sets
  35. # up a non-interactive environment.
  36. #
  37. # NB: this shell script is assumed to be run from the
  38. #     top of the spooling hierarchy -- s.t. the etc directory
  39. #     is present.
  40. #
  41.  
  42. test -f etc/setup.cache || {
  43.     SPOOL=`pwd`
  44.     cat<<EOF
  45.  
  46. FATAL ERROR: $SPOOL/etc/setup.cache is missing!
  47.  
  48. The file $SPOOL/etc/setup.cache is not present.  This
  49. probably means the machine has not been setup using the faxsetup(1M)
  50. command.  Read the documentation on setting up HylaFAX before you
  51. startup a server system.
  52.  
  53. EOF
  54.     exit 1
  55. }
  56. . etc/setup.cache
  57.  
  58. PS=$GSRIP
  59.  
  60. fil=
  61. out=pdf.fax        # default output filename
  62. pagewidth=1728        # standard fax width
  63. pagelength=297        # default to A4 
  64. vres=98            # default to low res
  65. device=tiffg3        # default to 1D
  66. while test $# != 0
  67. do
  68.     case "$1" in
  69.     -o)    shift; out="$1" ;;
  70.     -w) shift; pagewidth="$1" ;;
  71.     -l) shift; pagelength="$1" ;;
  72.     -r)    shift; vres="$1" ;;
  73.     -m) shift;;                # NB: not implemented
  74.     -1) device=tiffg3 ;;
  75.     -2) ($PS -h | grep tiffg32d >/dev/null 2>&1) \
  76.         && { device=tiffg32d; } \
  77.         || { device=tiffg3; }
  78.     ;;
  79.     -*)    ;;
  80.     *)    fil="$fil $1" ;;
  81.     esac
  82.     shift
  83. done
  84. test -z "$fil" && fil="-"        # read from stdin
  85. case "${pagewidth}x${pagelength}" in
  86. 1728x280|1728x279)        # 279.4mm is actually correct...
  87.     paper=letter;;
  88. 1728x364) 
  89.     paper=legal;;
  90. *x296|*x297)            # more roundoff problems...
  91.     paper=a4;;
  92. *x364)
  93.     paper=b4;;
  94. *)
  95.     echo "$0: Unsupported page size: $pagewidth x $pagelength";
  96.     exit 254;;            # causes document to be rejected
  97. esac
  98.  
  99. #
  100. # The sed work fixes bug in Windows-generated
  101. # PostScript that causes certain international
  102. # character marks to be placed incorrectly.
  103. #
  104. #    | $SED -e 's/yAscent Ascent def/yAscent 0 def/g' \
  105. #
  106. # NB: unfortunately it appears to break valid PostScript;
  107. #     so it's been disabled.
  108. #
  109. # Suggestion from "Alan Sparks" <asparks@nss.harris.com>,
  110. # Add the -DFIXEDMEDIA argument to the last command in ps2fax
  111. #
  112. $PS -q \
  113.     -sDEVICE=$device \
  114.     -dNOPAUSE \
  115.     -dSAFER=true \
  116.     -sPAPERSIZE=$paper \
  117.     -dFIXEDMEDIA \
  118.     -dBATCH \
  119.     -r204x$vres \
  120.     "-sOutputFile=$out" \
  121.     $fil
  122.